﻿using System.ComponentModel;
using System.Windows.Media;
using Loki.UI;
using Loki.Utils;
using Luna.Model.Budget;

namespace Luna.UI.Budget
{
    public class DisplayableCategory : LunaDisplayable
    {
        #region Name

        private static PropertyChangedEventArgs _NameChangedArgs = ObservableHelper.CreateChangedArgs<DisplayableCategory>(x => x.Name);

        private static PropertyChangingEventArgs _NameChangingArgs = ObservableHelper.CreateChangingArgs<DisplayableCategory>(x => x.Name);

        private string _Name;

        public string Name
        {
            get
            {
                return _Name;
            }

            set
            {
                if (value != _Name)
                {
                    NotifyChanging(_NameChangingArgs);
                    _Name = value;
                    NotifyChangedAndDirty(_NameChangedArgs);
                }
            }
        }

        #endregion Name

        #region Description

        private static PropertyChangedEventArgs _DescriptionChangedArgs = ObservableHelper.CreateChangedArgs<DisplayableCategory>(x => x.Description);

        private static PropertyChangingEventArgs _DescriptionChangingArgs = ObservableHelper.CreateChangingArgs<DisplayableCategory>(x => x.Description);

        private string _Description;

        public string Description
        {
            get
            {
                return _Description;
            }

            set
            {
                if (value != _Description)
                {
                    NotifyChanging(_DescriptionChangingArgs);
                    _Description = value;
                    NotifyChangedAndDirty(_DescriptionChangedArgs);
                }
            }
        }

        #endregion Description

        #region Color

        private static PropertyChangedEventArgs _ColorChangedArgs = ObservableHelper.CreateChangedArgs<DisplayableCategory>(x => x.Color);

        private static PropertyChangingEventArgs _ColorChangingArgs = ObservableHelper.CreateChangingArgs<DisplayableCategory>(x => x.Color);

        private Color _Color;

        public Color Color
        {
            get
            {
                return _Color;
            }

            set
            {
                if (value != _Color)
                {
                    NotifyChanging(_ColorChangingArgs);
                    _Color = value;
                    NotifyChangedAndDirty(_ColorChangedArgs);
                }
            }
        }

        #endregion Color

        public DisplayableCategory()
        {
            AddValidator<DisplayableCategory, string>(x => x.Name, Rules.Required, "Le nom est requis.");
        }

        public IEditableCategory Category
        {
            get;
            set;
        }
    }
}